package com.ruoyi.process.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.process.domain.ApprObj;
import com.ruoyi.process.domain.workflow.ApprObjDTO;
import com.ruoyi.process.domain.workflow.ApprParam;
import com.ruoyi.process.domain.workflow.ApprQuery;
import com.ruoyi.process.service.IFlowTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 流程任务的操作
 */
@RestController
@RequestMapping("/workflow/flowTask")
public class FlowTaskController  extends BaseController {
    @Autowired
    private IFlowTaskService flowTaskService;
    //操作选项目
    /**
     * 审批同意
     */
    @PostMapping("/agree")
    public AjaxResult agree(@RequestBody ApprParam params) {
        System.out.println("params:"+params);
          flowTaskService.agree(params);
        return AjaxResult.success();
    }

    /**
     * 审批拒绝
     */
    @PostMapping("/refuse")
    public AjaxResult refuse(@RequestBody ApprParam params) {
        flowTaskService.refuse(params);
        return AjaxResult.success();
    }

    /**
     * 审批转办
     */
    @PostMapping("/transfer")
    public AjaxResult transfer(@RequestBody ApprParam params) {
        flowTaskService.transfer(params);
        return AjaxResult.success();
    }

    /**
     * 审批委派
     */
    @PostMapping("/delegate")
    public AjaxResult delegate(@RequestBody ApprParam params) {
        flowTaskService.delegate(params);
        return AjaxResult.success();
    }

    /**
     * 加签
     * @param params
     * @return
     */


    @GetMapping(value = "/addsignlabel")
    public AjaxResult addsignlabel(ApprParam params) {
        flowTaskService.addsigntask(params);
        return AjaxResult.success("加签成功");
    }
//   查询选项
    /**
     * 我的待办
     */
    @GetMapping("/todolist")
    public TableDataInfo todolist(ApprQuery apprQuery) {
         startPage();
        List<ApprObj> todolists = flowTaskService.getTodoList(apprQuery);
        return  getDataTable(todolists);
    }
    /**
     * 已审批记录
     */
    @GetMapping("/apprList")
    public TableDataInfo apprList(ApprQuery apprQuery) {
        startPage();
        List<ApprObjDTO> todolists = flowTaskService.apprList(apprQuery);
        return  getDataTable(todolists);
    }
    /**
     * 我的流程
     */
    @GetMapping("/ownerList")
    public TableDataInfo ownerList(ApprQuery apprQuery) {
        startPage();
        List<ApprObjDTO> todolists = flowTaskService.myprocessList(apprQuery);
        return  getDataTable(todolists);
    }



}
